﻿<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>BootStrap Table使用</title>
    <link href="~/css/bootstrap-select.css" rel="stylesheet" />
    <link href="~/css/bootstrap-table.css" rel="stylesheet" />
    <link href="~/css/bootstrap.css" rel="stylesheet" />
    <link href="~/css/ui-dialog.css" rel="stylesheet" />
    <link href="/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="~/css/labelauty.css" rel="stylesheet" />

    <link href="~/css/lsj.css" rel="stylesheet" />


    <script src="~/js/jquery.min.js"></script>
    @*<script src="~/js/jquery.unobtrusive-ajax.js"></script>*@
    <script src="~/js/jquery-form.js"></script>
    <script src="~/js/bootstrap.js"></script>
    <script src="~/js/bootstrap-select.js"></script>
    <script src="~/js/bootstrap-table.js"></script>
    <script src="~/js/bootstrap-table-zh-CN.js"></script>
    <script src="/js/content.min.js?v=1.0.0"></script>
    <script src="~/js/dialog-plus-min.js"></script>
    <script src="~/js/labelauty.js"></script>

    @*富文本*@
    <script src="~/editor/kindeditor.js"></script>

    <script src="~/js/lsj/news.js"></script>
    <script src="~/js/plugins/layer/laydate/laydate.js"></script>


</head>
<body>
    <div class="panel-body" style="padding-bottom:0px;">
        @using Common;
        @using Web.helper;
        @{
            var actionName = ViewContext.RouteData.Values["action"].ToString().ToLower();
            var manager_id = User.Identity.Name;
            var imagespath = ViewData["imagespath"].ToString();
        }
        @Html.Raw(Html.select_auth(manager_id, actionName))
        <table id="tb_departments"></table>
    </div>
    @using (Ajax.BeginForm("AddNews", "Templet",new { }, new AjaxOptions() { HttpMethod = "Post", OnSuccess = "tips(data)", OnBegin = "ValidateLog" }, new { enctype = "multipart/form-data" }))
    {
            <div class="modal fade bs-example-modal-lg" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="z-index:1000">
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title" id="myModalLabel">新增</h4>
                        </div>
                        <div class="modal-body">
                            <input type="hidden" name="id" class="form-control" id="id">
                            <ul id="myTab" class="nav nav-tabs">
                                <li class="active"><a href="#home" data-toggle="tab">基本信息</a></li>
                                <li><a href="#detailed" data-toggle="tab">详细描述</a></li>
                                <li><a href="#seo" data-toggle="tab">SEO选项</a></li>
                            </ul>
                            <div id="myTabContent" class="tab-content">
                                <div class="tab-pane fade in active" id="home">
                                    <div class="form-group">
                                        <label for="txt_departmentname">上级编号</label>
                                        @Html.Raw(Html.select_new())
                                    </div>
                                    <div class="form-group">
                                        <label for="txt_departmentname">显示状态</label>
                                        <input type="hidden" id="txt_is_lock" name="txt_is_lock" value="√" /> @*用一个隐藏元素保存选中状态*@
                                        <div class="rdo">
                                            <input type="radio" name="rdo" class="rdolist" checked="checked" />
                                            <label class="rdobox">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">显示</span>
                                            </label>
                                            <input type="radio" name="rdo" class="rdolist" />
                                            <label class="rdobox">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">隐藏</span>
                                            </label>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="txt_parentdepartment">推荐类型</label>
                                        <input type="hidden" id="txt_action_type" name="txt_action_type" value="√" /> @*用一个隐藏元素保存选中状态*@
                                        <!-- 多选 -->
                                        <div class="fuxuan">

                                            <input type="checkbox" name="chk" class="chklist" checked="checked" />
                                            <!--  -->
                                            <label class="chkbox">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">@EnumBase.RecommendType.置顶.Description()</span>
                                            </label>
                                            <!--  -->
                                            <input type="checkbox" name="chk" class="chklist" />
                                            <!--  -->
                                            <label class="chkbox">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">@EnumBase.RecommendType.推荐.Description()</span>
                                            </label>
                                            <!--  -->
                                            <input type="checkbox" name="chk" class="chklist" />
                                            <!--  -->
                                            <label class="chkbox">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">@EnumBase.RecommendType.热门.Description()</span>
                                            </label>
                                            <!--  -->
                                            <input type="checkbox" name="chk" class="chklist" />
                                            <!--  -->
                                            <label class="chkbox">
                                                <span class="check-image"></span>
                                                <span class="radiobox-content">@EnumBase.RecommendType.允许评论.Description()</span>
                                            </label>
                                            <!--  -->
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="txt_departmentname">标题</label>
                                        <input type="text" name="txt_title" class="form-control" id="txt_title" placeholder="标题(必填)">
                                    </div>
                                    <div class="form-group">
                                        <label class="font-noraml">封面图片</label>
                                        <div class="input-group">
                                            <span class="input-group-addon">上传图片</span>
                                            <input type="file" name="file1" id="fileImage" style="display:none" class="form-control" onchange="previewImage(this)">
                                            <input type="text" id="txt_img_url" name="txt_img_url" class="form-control" placeholder="封面图片" onclick="javascript:openBrowse();">
                                        </div>
                                        <div id="preview" style="width:120px; height:120px;border:0px;margin:20px 0px 20px 0px;overflow:hidden;">
                                            <img id="imghead" style="border:0px;width:120px; height:120px">
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label for="txt_parentdepartment">排序</label>
                                        <input type="text" name="txt_sort_id" class="form-control" id="txt_sort_id" placeholder="数字越小越靠前">
                                    </div>
                                    <div class="form-group">
                                        <label for="txt_parentdepartment">浏览次数</label>
                                        <input type="text" name="txt_click" class="form-control" id="txt_click" placeholder="">
                                    </div>
                                    <div class="form-group">
                                        <label for="txt_parentdepartment">发布时间</label><br />
                                        <input placeholder="发布时间" class="laydate-icon form-control layer-date" id="start_time" name="start_time" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})">
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="detailed">
                                    <div class="form-group">
                                        <label for="txt_departmentname">信息来源</label>
                                        <input type="text" name="txt_source" class="form-control" id="txt_source" placeholder="来源" >
                                    </div>
                                    <div class="form-group">
                                        <label for="txt_departmentname">文章作者</label>
                                        <input type="text" name="txt_author" class="form-control" id="txt_manager" placeholder="作者">
                                    </div>
                                    <div class="form-group">
                                        <label for="txt_parentdepartment">内容摘要</label>
                                        <input type="text" name="txt_summary" class="form-control" id="txt_summary">
                                    </div>
                                    <div class="form-group">
                                        <label for="txt_parentdepartment">内容</label>
                                        <textarea id="txtContent" name="txtContent" class="editor" style="visibility:hidden;"></textarea>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="seo">
                                    <div class="form-group">
                                        <label for="txt_parentdepartment">SEO标题</label>
                                        <input type="text" name="txt_seo_title" class="form-control" id="txt_seo_title">
                                    </div>
                                    <div class="form-group">
                                        <label for="txt_departmentname">SEO关键字</label>
                                        <textarea class="form-control" rows="3" id="txt_seo_keywords" name="txt_seo_keywords"></textarea>
                                    </div>
                                    <div class="form-group">
                                        <label for="txt_parentdepartment">SEO描述</label>
                                        <textarea class="form-control" rows="3" id="txt_seo_description" name="txt_seo_description"></textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
                            <button class="btn btn-primary block full-width m-b" id="btn_submit" onclick="onck()"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
                        </div>
                    </div>
                </div>
            </div>
    }

    @using (Ajax.BeginForm("ExamNews", "Templet", new { }, new AjaxOptions() { HttpMethod = "Post", OnSuccess = "tips(data)", OnBegin = "ValidateLog" }, new { enctype = "multipart/form-data" }))
    {
        <div class="modal fade bs-example-modal-sm" id="myExam" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" style="z-index:1000">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel">审核</h4>
                    </div>
                    <div class="modal-body">
                        <div class="form-group">
                            <input type="hidden" id="txt_status" name="txt_status" value="0" /> @*用一个隐藏元素保存选中状态*@
                            <input type="hidden" id="ids" name="ids" value="0" /> @*用一个隐藏元素保存选中数据*@
                            <div class="rdo">
                                <input type="radio" name="rdo" class="rdolist" checked="checked" />
                                <label class="rdobox">
                                    <span class="check-image"></span>
                                    <span class="radiobox-content">@EnumBase.ExamType.未审核.Description()</span>
                                </label>
                                <input type="radio" name="rdo" class="rdolist" />
                                <label class="rdobox">
                                    <span class="check-image"></span>
                                    <span class="radiobox-content">@EnumBase.ExamType.成功.Description()</span>
                                </label>
                                <input type="radio" name="rdo" class="rdolist" />
                                <label class="rdobox">
                                    <span class="check-image"></span>
                                    <span class="radiobox-content">@EnumBase.ExamType.失败.Description()</span>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
                        <button class="btn btn-primary block full-width m-b" id="btn_submit"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
                    </div>
                </div>
            </div>
        </div>
    }
</body>
</html>


<script>
    var imagespath = '@imagespath';
    $(document).ready(function () {
        //参数{input类名，选择类型(单选or多选)}
        $(".rdolist").labelauty("rdolist", "rdo");
        $("#myModal .chklist").labelauty("chklist", "check");

        $("#myModal .rdobox").click(function () {
            if ($(this).html() == $("#myModal .rdobox:first").html()) {
                //显示
                $("#txt_is_lock").val("√");
            } else {
                //隐藏
                $("#txt_is_lock").val("×");
            }
        })

        $("#myExam .rdobox").click(function () {
            if ($(this).html() == $("#myExam .rdobox:first").html()) {
                //未审核
                $("#txt_status").val("0");
            } else if ($(this).html() == $("#myExam .rdobox").eq(1).html()) {
                //成功
                $("#txt_status").val("1");
            } else
            {
                //失败
                $("#txt_status").val("2");
            }
        })

    });
    $('#myModal').on('show.bs.modal', function (e) {
        $(".chkbox").each(function () {
            $(this).prev().prop("checked", "");
            $(this).removeClass("checked");
            $(this).addClass("unchecked");
            $(this).children(".check-image").css("background", "url(../img/input-unchecked.png)");
        });
    })

</script>



<script>

    //提交的onclick,此时还可以修改表单里面的值,且后台可以获取
    function onck() {
        $('.selectpicker').selectpicker('refresh');//不加这个,默认显示无法获取
        //获取多选的值
        var action_type = "";
        $(".chkbox").each(function () {
            if ($(this).prev().prop("checked") == true) {
                action_type += $(this).children(".radiobox-content").html() + ",";
            }
        })
        if (action_type.length > 0) {
            action_type = action_type.substring(0, action_type.length - 1);
            $("#txt_action_type").val(action_type);

        } else {
            $("#txt_action_type").val('');
        }
    }


    //登录回调函数
    function tips(data) {
        var d = dialog({
            padding: 30,
            content: data.msg
        });

        if (data.status == 0) {
            //添加成功

            //显示模态框
            d.show();
            //先关闭主窗体
            $('#myModal').modal('hide')
            $('#myExam').modal('hide')
            //刷新数据
            $('#tb_departments').bootstrapTable('refresh', { url: '/Templet/GetNewsList' });
            //关闭提示模态框
            setTimeout(function () {
                d.close().remove();
            }, 2000);
        } else if (data.pitchId != "") {
            point(data.pitchId, data.msg);
        } else {
            //添加失败
            d = dialog({
                padding: 30,
                content: data.msg
            });
            //关闭提示模态框
            setTimeout(function () {
                d.close().remove();
            }, 2000);
        }
    }

    //输出提示信息
    function point(id, content) {
        var follow = document.getElementById(id);
        var d = dialog({
            align: 'bottom',
            content: '<span class="label label-warning">!</span> ' + content
        });
        d.show(follow);
        setTimeout(function () {
            d.close().remove();
        }, 2000);
    }

</script>
<script>
    (function () {
        $('form').ajaxForm({
            beforeSend: function () {
            },
            uploadProgress: function (event, position, total, percentComplete) {
            },
            success: function (data) {
                tips(data);
            },
            complete: function (xhr) {
            }
        });

    })();
</script>